<template>
  <page-body>
    <view class="page">
      <view class="flex align-stretch benben-position-layout flex recommendCommodityList_flex_0"
        :style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
        <view class='flex align-center justify-between flex-sub recommendCommodityList_fd0_0'>
          <view class='flex align-center' @tap="handleJumpDiy" data-type="back" data-url="1">
            <text class='fu-iconfont2  recommendCommodityList_fd0_0_c0_c0'>&#xE794;</text>
          </view>
          <view class='flex align-center flex-sub recommendCommodityList_fd0_0_c1'>
            <text class='fu-iconfont2  recommendCommodityList_fd0_0_c1_c0'>&#xe738;</text>
            <benben-input class='flex-sub recommendCommodityList_fd0_0_c1_c1' type="text" :placeholder="`请输入商品名称`"
              confirm-type="done" :maxlength="-1" placeholder-style="color:rgba(191, 191, 191, 1);font-size:28rpx"
              @confirm="getPostlistFunc()" v-model="keyword" />
            <image class='recommendCommodityList_fd0_0_c1_c2' mode="aspectFit" :src='STATIC_URL+"105.png"'
              @tap.stop="clearSearchFunc()"></image>
          </view>
        </view>

      </view>
      <view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
      <!---flex布局flex布局开始-->
      <view class="flex flex-direction align-stretch benben-flex-layout recommendCommodityList_flex_1">
        <view>
          <benben-flex-tabs class-name='recommendCommodityList_benbenTabsfd1_0' v-model="tabsTypefd1_0"
            ref="benben_tabsfd1_0" select-mark="benben_tabsfd1_0" key="benben_tabsfd1_0" :open-title-type='false'
            :open-sticky='true' :top='90' :is-show-content='false' :scrollspy='false' :tabs-info.sync="tabsInfofd1_0">

            <scroll-view @scroll="tabsInfofd1_0.scrollX = $event.detail.scrollLeft" id="benben_tabsfd1_0"
              class="benben-tabs" style="width:750rpx" :scroll-x="true" :scroll-left.sync="tabsInfofd1_0.moveX"
              scroll-with-animation="all .3s ease">
              <view class="benben-tabs-content" id="benben_tabsfd1_0-content">
                <view id="benben_tabsfd1_0-title" class="benben-tabs-title flex flex align-center justify-around">
                  <view :class="{ 'checkTitlefd1_0': tabsTypefd1_0 == '1', 'flex flex-wrap align-center': true }"
                    @tap="chengTab('1')" :id="`benben_tabsfd1_0-title-item-${'1'}`">

                    <text>动态</text>

                  </view>
                  <view :class="{ 'checkTitlefd1_0': tabsTypefd1_0 == '2', 'flex flex-wrap align-center': true }"
                    @tap="chengTab('2')" :id="`benben_tabsfd1_0-title-item-${'2'}`">

                    <text>发明</text>

                  </view>
                  <view :class="{ 'checkTitlefd1_0': tabsTypefd1_0 == '3', 'flex flex-wrap align-center': true }"
                    @tap="chengTab('3')" :id="`benben_tabsfd1_0-title-item-${'3'}`">

                    <text>二手</text>

                  </view>
                </view>
                <view :style="{ left: tabsInfofd1_0.lineleft, maxWidth: tabsInfofd1_0.lineWidth ,}"
                  id="benben_tabsfd1_0-line"
                  class="benben-tabs-line flex benben-flex-tabs-line recommendCommodityList_linefd1_0"></view>
              </view>
            </scroll-view>

          </benben-flex-tabs>

        </view>

        <view class='flex flex-wrap align-center justify-between recommendCommodityList_fd1_1'>
          <view class='flex flex-wrap align-center' @click.stop="search('aid',sort_type)">
            <text class='recommendCommodityList_fd1_1_c0_c0' :class="sort_field=='aid' ? 'active' :''">按时间</text>
            <view class='flex flex-direction flex-wrap align-center'>
              <!-- 上黑 -->
              <image class='recommendCommodityList_fd1_1_c0_c1_c0' v-if="sort_type!='asc'" mode="aspectFit"
                :src='STATIC_URL+"167.png"'></image>
              <!-- 上绿 -->
              <image v-if="sort_type=='asc'" class='recommendCommodityList_fd1_1_c0_c1_c0' mode="aspectFit"
                :src='STATIC_URL+"202.png"'></image>
              <!-- 下绿 -->
              <image v-if="sort_type=='desc'" class='recommendCommodityList_fd1_1_c0_c1_c1' mode="aspectFit"
                :src='STATIC_URL+"168.png"'></image>
              <!-- 下黑 -->
              <image v-if="sort_type!='desc'" class='recommendCommodityList_fd1_1_c0_c1_c1' mode="aspectFit"
                :src='STATIC_URL+"203.png"'></image>
            </view>
          </view>
          <view class='flex flex-wrap align-center' @click.stop="search('viewcount',sort_type1)">
            <text class='recommendCommodityList_fd1_1_c0_c0' :class="sort_field=='viewcount' ? 'active' :''">热度</text>
            <view class='flex flex-direction flex-wrap align-center'>
              <!-- 上黑 -->
              <image class='recommendCommodityList_fd1_1_c0_c1_c0' v-if="sort_type1!='asc'" mode="aspectFit"
                :src='STATIC_URL+"167.png"'></image>
              <!-- 上绿 -->
              <image v-if="sort_type1=='asc'" class='recommendCommodityList_fd1_1_c0_c1_c0' mode="aspectFit"
                :src='STATIC_URL+"202.png"'></image>
              <!-- 下绿 -->
              <image v-if="sort_type1=='desc'" class='recommendCommodityList_fd1_1_c0_c1_c1' mode="aspectFit"
                :src='STATIC_URL+"168.png"'></image>
              <!-- 下黑 -->
              <image v-if="sort_type1!='desc'" class='recommendCommodityList_fd1_1_c0_c1_c1' mode="aspectFit"
                :src='STATIC_URL+"203.png"'></image>
            </view>
          </view>
          <view class='flex flex-wrap align-center' @click.stop="search('exhibition',sort_type2)">
            <text class='recommendCommodityList_fd1_1_c0_c0' :class="sort_field=='exhibition' ? 'active' :''">价格</text>
            <view class='flex flex-direction flex-wrap align-center'>
              <!-- 上黑 -->
              <image class='recommendCommodityList_fd1_1_c0_c1_c0' v-if="sort_type2!='asc'" mode="aspectFit"
                :src='STATIC_URL+"167.png"'></image>
              <!-- 上绿 -->
              <image v-if="sort_type2=='asc'" class='recommendCommodityList_fd1_1_c0_c1_c0' mode="aspectFit"
                :src='STATIC_URL+"202.png"'></image>
              <!-- 下绿 -->
              <image v-if="sort_type2=='desc'" class='recommendCommodityList_fd1_1_c0_c1_c1' mode="aspectFit"
                :src='STATIC_URL+"168.png"'></image>
              <!-- 下黑 -->
              <image v-if="sort_type2!='desc'" class='recommendCommodityList_fd1_1_c0_c1_c1' mode="aspectFit"
                :src='STATIC_URL+"203.png"'></image>
            </view>
          </view>
        </view>
      </view>

      <!---flex布局flex布局结束-->
      <!---flex布局flex布局开始-->
      <view class="flex flex-wrap align-center benben-flex-layout recommendCommodityList_flex_2">
        <view class='flex flex-wrap align-center recommendCommodityList_fd2_0' v-for="(item,index) in dataList"
          :key="index" @tap.stop="handleJumpDiy" data-type="navigateTo"
          :data-url="`/pages/homePage/detail/detail?aid=${item.aid}`">
          <image class='recommendCommodityList_fd2_0_c0' mode="aspectFill" :src='item.picture[0]'></image>
          <view class='flex flex-direction flex-wrap align-stretch recommendCommodityList_fd2_0_c1'>
            <text class='recommendCommodityList_fd2_0_c1_c0'>{{item.title}}</text>
            <view class='flex flex-wrap align-center justify-between recommendCommodityList_fd2_0_c1_c1'>
              <text class='recommendCommodityList_fd2_0_c1_c1_c0'>{{item.exhibition_name}}</text>
              <view class='flex flex-wrap align-center'>
                <text class='recommendCommodityList_fd2_0_c1_c1_c1_c0'>{{item.viewcount}} 浏览</text>
              </view>
            </view>
          </view>
        </view>
        <fu-empty :pagingListLoadedAll="pagingListLoadedAll" :pagingListNoListData="pagingListNoListData"
          :listDataLength="listDataLength" :isLoadInit="isLoadInit"></fu-empty>
      </view>

      <!---flex布局flex布局结束-->


    </view>
  </page-body>
</template>
<script>
  import pagingList from '@/common/mixin/paging_list.js';
  export default {
    components: {},
    mixins: [pagingList],

    data() {
      return {
        "tabsInfofd1_0": {
          lineleft: '',
          lineWidth: '',
          moveX: 0,
          scrollX: 0,
          PageScrollX: 0
        },
        "tabsTypefd1_0": "1",
        "allshow": false,
        "all_name": "全部",
        "screenshow": false,
        "show_id": "1",
        "dataList": [],
        "userList": [],
        "is_recommend": "",
        "grass_type": "",
        "keyword": "",
        "cid": "",
        "minixPagingListsApi": "",
        "pageingListApiMethod": "",
        "allowOnloadGetList": false,
        "bannerList": [],
        "dataList": [],
        sort_field: 'aid',
        sort_type: 'desc',
        sort_type1: 'desc',
        sort_type2: 'desc',
      };
    },
    computed: {

    },
    watch: {},
    onLoad(options) {
      let {
        keyword,
        cid
      } = options
      if (keyword !== undefined) this.keyword = keyword
      if (cid !== undefined) this.cid = cid
    },
    onUnload() {

    },
    onReady() {

    },
    onShow() {
      this.getPostlistFunc()
    },
    onHide() {

    },
    onResize() {

    },
    onPullDownRefresh() {

    },
    onReachBottom(e) {

    },
    onPageScroll(e) {

    },
    methods: {
      search(type, status) {
        this.sort_field = type
        // this.sort_type = 'desc'
        console.log('ppp', status)
        if (type == 'aid') {
          if (this.sort_type == 'desc') {
            this.sort_type = 'asc'
          } else {
            this.sort_type = 'desc'
          }
        }
        if (type == 'viewcount') {
          if (this.sort_type1 == 'desc') {
            this.sort_type1 = 'asc'
          } else {
            this.sort_type1 = 'desc'
          }
        }
        if (type == 'exhibition') {
          if (this.sort_type2 == 'desc') {
            this.sort_type2 = 'asc'
          } else {
            this.sort_type2 = 'desc'
          }
        }
        this.getPostlistFunc()
      },
      searcItem() {
        if (this.sort_type == 'desc') {
          this.sort_type = 'asc'
        } else {
          this.sort_type = 'desc'
        }
        this.getPostlistFunc()
      },
      //搜索
      chengTab(type) {
        this.tabsTypefd1_0 = type
        this.getPostlistFunc()
      },
      getPostlistFunc() {
        let status = ''
        if (this.sort_field == 'aid') {
          status = this.sort_type
        }
        if (this.sort_field == 'viewcount') {
          status = this.sort_type1
        }
        if (this.sort_field == 'exhibition') {
          status = this.sort_type2
        }

        this.minixPagingListsApi = global.apiUrls.post6698cbe11f907;
        this.pageingListApiMethod = 'post';
        this.allowOnloadGetList = false;
        this.pagingListPostDataContent = {
          freetransactionclassification_id: this.tabsTypefd1_0,
          sort_field: this.sort_field,
          sort_type: status,
          title: this.keyword
        }
        this.listData = [];
        this.dataList = this.listData;
        this.pagingListToggle();
      },
      pagingListPostData() {
        return this.pagingListPostDataContent
      },
      //清除搜索框
      clearSearchFunc() {
        this.keyword = '';
        this.getPostlistFunc()
      }
    }
  };
</script>
<style lang="scss" scoped>
  .page {
    width: 100vw;
    overflow-x: hidden;
    min-height: calc(100vh - var(--window-bottom));
    background: #F8F8F8;
    background-size: 100% auto;
  }

  .recommendCommodityList_flex_0 {
    background: #fff;
    width: 750rpx;
    height: 88rpx;
    overflow: hidden;
    z-index: 10;
    top: 0rpx;
    background-size: 100% auto !important;
  }

  .recommendCommodityList_fd0_0_c1_c2 {
    width: 20rpx;
    height: 20rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
  }

  .recommendCommodityList_fd0_0_c1_c1 {
    font-size: 28rpx;
    font-weight: 400;
    color: var(--benbenFontColor0);
  }

  .recommendCommodityList_fd0_0_c1_c0 {
    font-size: 24rpx;
    color: rgba(153, 153, 153, 1);
    margin: 0rpx 14rpx 0rpx 0rpx;
  }

  .recommendCommodityList_fd0_0_c1 {
    background: #F9F9F9;
    height: 64rpx;
    border-radius: 34rpx 34rpx 34rpx 34rpx;
    padding: 0rpx 24rpx 0rpx 24rpx;
    margin: 0rpx 0rpx 0rpx 32rpx;
  }

  .recommendCommodityList_fd0_0_c0_c0 {
    font-size: 36rpx;
    font-weight: 500;
    color: #333;
  }

  .recommendCommodityList_fd0_0 {
    padding: 0rpx 24rpx 0rpx 24rpx;
    line-height: 88rpx;
  }

  .recommendCommodityList_flex_1 {
    background: var(--benbenbgColor1);
    background-size: 100% auto;
  }

  .recommendCommodityList_fd1_1_c0_c1_c1 {
    width: 10rpx;
    height: 6rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
  }

  .recommendCommodityList_fd1_1_c0_c1_c0 {
    width: 10rpx;
    height: 6rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
    margin: 0rpx 0rpx 8rpx 0rpx;
  }

  .recommendCommodityList_fd1_1_c0_c0 {
    margin: 0rpx 16rpx 0rpx 0rpx;
    color: #333;

    &.active {
      color: #176BE8;
    }
  }

  .recommendCommodityList_fd1_1 {
    width: 500rpx;
    padding: 24rpx 0rpx 24rpx 24rpx;
  }

  .recommendCommodityList_linefd1_0 {
    background: url(image-path('161.png')) no-repeat;
    width: 50rpx;
    height: 12rpx;
    top: 70rpx;
    background-size: 100% auto !important;
  }

  .checkTitlefd1_0 {
    font-weight: 700 !important;
    font-size: 32rpx !important;
    color: #176BE8 !important;
    background-color: rgba(255, 255, 255, 1) !important;
  }

  ::v-deep .recommendCommodityList_benbenTabsfd1_0 {
    background: #fff;
    width: 750rpx;
    height: 90rpx;
    white-space: nowrap;
    text-align: center;
    color: var(--benbenFontColor1);
  }

  .recommendCommodityList_flex_2 {
    // padding: 0rpx 16rpx 0rpx 16rpx;
    width: 702rpx;
    margin: 0 auto;
  }

  .recommendCommodityList_fd2_0_c1_c1_c1_c0 {
    font-size: 24rpx;
    color: rgba(153, 153, 153, 1);
  }

  .recommendCommodityList_fd2_0_c1_c1_c0 {
    font-weight: 600;
    color: rgba(255, 72, 59, 1);
  }

  .recommendCommodityList_fd2_0_c1_c1 {
    margin: 24rpx 0rpx 0rpx 0rpx;
  }

  .recommendCommodityList_fd2_0_c1_c0 {
    -webkit-line-clamp: 2;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    height: 80rpx
  }

  .recommendCommodityList_fd2_0_c1 {
    margin: 24rpx auto 20rpx auto;
    width: 320rpx;
  }

  .recommendCommodityList_fd2_0_c0 {
    width: 346rpx;
    height: 346rpx;
    border-radius: 16rpx 16rpx 0rpx 0rpx;
  }

  .recommendCommodityList_fd2_0 {
    background: #FFFFFF;
    border-radius: 16rpx 16rpx 16rpx 16rpx;
    width: 346rpx;
    margin: 16rpx 0 0rpx 0rpx;
  }

  .recommendCommodityList_fd2_0:nth-child(2n) {
    margin: 16rpx 0 0rpx 10rpx;
  }
</style>
